package 行为型模式.命令模式;

import java.util.Map;
import java.util.Set;

/**
 * @Description 具体的命令类
 * @Author shallow
 * @Date 2023/3/8 9:50
 */

public class OrderCommand implements Command{

    //持有接受者对象
    private SeniorChef receiver;
    private Order order;

    public OrderCommand(SeniorChef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable()+"桌的订单：");
        Map<String, Integer> foodDir = order.getFoodDir();
        //遍历map集合
        Set<String> keys = foodDir.keySet();
        keys.stream().forEach(food->{
            receiver.makeFood(food,foodDir.get(food));
        });
        System.out.println(order.getDiningTable()+"桌的饭准备完毕");
    }
}
